﻿//++
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
// Module Name:
//
//  ServerContextTest.cs
//    
// Abstract:
//
//  Unit tests for the ServerContext class.
//  
//--

using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Microsoft.EnhancedReminders.Common.UnitTests
{
    /// <summary>
    ///This is a test class for ServerContextTest and is intended
    ///to contain all ServerContextTest Unit Tests
    ///</summary>
    [TestClass()]
    public class ServerContextTest
    {
        /// <summary>
        /// Tests that the return value of ServerContetx.ExtendedPropertiesToXmlString is formatted correctly when only 
        /// an e-mail address is specified.
        /// </summary>
        [TestMethod()]
        public void ExtendedPropertiesToXmlStringEmailOnlyTest()
        {
            string expectedEmailAddress = "john@contoso.com";
            ServerContext context = new ServerContext(expectedEmailAddress);
            Assert.AreEqual<string>(
                ServerContext_Accessor.EmailStartTag + expectedEmailAddress + ServerContext_Accessor.EmailEndTag,
                context.ExtendedPropertiesToXmlString());
        }

        /// <summary>
        /// Tests that the return value of ServerContetx.ExtendedPropertiesToXmlString is formatted correctly when both 
        /// an e-mail and mailbox item ID are specified.
        /// </summary>
        [TestMethod()]
        public void ExtendedPropertiesToXmlStringEmailAndMailIdTest()
        {
            string expectedEmailAddress = "john@contoso.com";
            string expectedMailItemId = "abcdefghijklmnopqrstuvwxyz";
            ServerContext context = new ServerContext(expectedEmailAddress, expectedMailItemId);
            Assert.AreEqual<string>(
                ServerContext_Accessor.EmailStartTag + expectedEmailAddress + ServerContext_Accessor.EmailEndTag + 
                ServerContext_Accessor.MailItemIdStartTag + expectedMailItemId + ServerContext_Accessor.MailItemIdEndTag, 
                context.ExtendedPropertiesToXmlString());
        }
    }
}
